package lc.数组;

/**
 * @description: 搜索二维矩阵 II
 * @author: qian
 * @createDate: 2021/8/25
 */
public class Math240 {

    public boolean searchMatrix(int[][] matrix, int target) {

        int row = matrix.length;
        int col = matrix[0].length -1;

        int a = 0;
        int b = col;
        while(a < row && b >= 0) {
            if(matrix[a][b] == target)
                return true;
            else if(matrix[a][b] > target)
                b--;
            else
                a++;
        }
        return false;
    }
}
